<template>
  <div>
    <el-dialog :title="generateDialog.title" :visible.sync="generateDialog.show" width="40%" destroy-on-close @close='closeDialog' @open='openDialog'
               :close-on-click-modal="false" :close-on-press-escape="false" :modal-append-to-body="false">
      <el-form ref="form" :model="formData" label-width="80px">
        <div class="flex" style="display: flex;">
          <el-form-item label="表名称:" prop="tableName">
            <el-input v-model="formData.tableName" disabled></el-input>
          </el-form-item>
          <el-form-item label="包名:" prop="packageName" style="margin-left:15px;">
            <el-input v-model="formData.packageName" placeholder="可为空，加载系统默认"></el-input>
          </el-form-item>
        </div>
        <div class="flex" style="display: flex;">
          <el-form-item label="作者:" prop="author">
            <el-input v-model="formData.author" placeholder="可为空，加载系统默认"></el-input>
          </el-form-item>
          <el-form-item label="模块:" prop="moduleName" style="margin-left:15px;">
            <el-input v-model="formData.moduleName" placeholder="可为空，加载系统默认"></el-input>
          </el-form-item>
        </div>
        <div class="flex" style="display: flex;">
          <el-form-item label="表前缀:" prop="tablePrefix">
            <el-input v-model="formData.tablePrefix" placeholder="可为空，加载系统默认"></el-input>
          </el-form-item>
          <el-form-item label="注释:" prop="comments" style="margin-left:15px;">
            <el-input v-model="formData.comments" placeholder="可为空，加载表默认"></el-input>
          </el-form-item>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="previewHandleView('form')" round>预览</el-button>
        <el-button size="mini" @click="download('form')" round>确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: ['generateDialog', 'formData'],
  data() {
    return {
        tableName: '',
        dsName: '',
    }
  },
  methods: {
    openDialog() {
        this.tableName = this.formData.tableName;
        this.dsName = this.formData.dsName;
    },
    closeDialog() {

    },
    previewHandleView(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit("previewHandleView")
        } else {
          console.log('查看失败!!');
          return false;
        }
      });

    },
    download(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit("download")
        } else {
          console.log('下载失败!!');
          return false;
        }
      });
    }
  },
}
</script>

<style lang="scss" scoped>
.dialog-footer {
  // text-align: center;
  display: flex;
  justify-content: center;
}
// .el-dialog__footer {
//   text-align: center !important;
//   display: flex;
//   justify-content: center;
// }
</style>